from bd09_2_wgs84 import gcj02_to_wgs84
import geohash
with open('data/hubei.csv', 'r') as f:
    rows = f.readlines()


# 17389
lnglat = rows[0].split(';')
G = []
for i, row in enumerate(lnglat):
    if '|' in row:
        continue
    lng, lat = list(map(float, row.split(',')))
    lng84, lat84 = gcj02_to_wgs84(lng, lat)
    G += [geohash.encode(lat84, lng84)]

G1 = [a[:8] for a in G]
G1set = list(set(G1))
print(len(G1set))

with open('res/bond.csv', 'w') as f:
    f.write('\n'.join(G1set))